<!DOCTYPE HTML>
<html>
<head>
    <title>系统发分</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 97%">
<div style="width:99%;height: 97%;">
    <div id="outImg">
        <img id="imgId" src="" alt="" onclick="smallImg()">
    </div>
    <div style="width:99%;">
        <div style="padding: 5px">
            <span>用户ID：</span><input  class="mini-textbox" type="text" id="userOId"/>
            <span style="margin-left: 20px;">用户名称：</span><input  class="mini-textbox" type="text" id="nickName"/>
            <span style="margin-left: 20px;">用户电话：</span><input  class="mini-textbox" type="number" id="mobilePhoneNumber"/>
            <a style="margin-left: 20px;" class="mini-button" iconCls="icon-search" onclick="search()">查找</a>
        </div>
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>
                        <a class="mini-button" iconCls="icon-remove" onclick="del()">刪除</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 97%;" multiSelect="true"
         url="/getdata/getSystemSendScoreList" idField="id" allowResize="true"
         sizeList="[20,30,50,100]" pageSize="20">
        <div property="columns">
            <div type="checkcolumn" width="20" ></div>
            <div field="objectId" width="80" headerAlign="center" allowSort="true" >objectId</div>
            <div field="userOId" width="80" headerAlign="center" align="center" allowSort="true" >用户ID</div>
            <div field="userNickName" width="80" headerAlign="center" align="center" allowSort="true" >用户名称</div>
            <div field="mobilePhoneNumber" width="80" headerAlign="center" align="center" allowSort="true" >用户电话</div>
            <div field="score" width="50" headerAlign="center" align="center" allowSort="true" >积分</div>
            <div field="type" width="50" headerAlign="center" align="center" allowSort="true">描述</div>
            <div field="updatedAt" Swidth="100" align="center" headerAlign="center" allowSort="true">更新日期</div>
            <div field="createdAt" Swidth="100" align="center" headerAlign="center" allowSort="true">创建日期</div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
  var flag = 1;
  mini.parse();
  var grid = mini.get("datagrid1");
  grid.load();
  grid.on("drawcell", function (e) {
    var value = e.value;
    var column = e.column;
  });
  function search() {
    let userOId = mini.get("userOId").getValue();
    if (!userOId){
      userOId = ''
    }
    let nickName = mini.get("nickName").getValue();
    if (!nickName){
      nickName = ''
    }
    let mobilePhoneNumber = mini.get("mobilePhoneNumber").getValue();
    if (!mobilePhoneNumber){
      mobilePhoneNumber = ''
    }
    grid.load({
      userOId:userOId,
      nickName:nickName,
      mobilePhoneNumber:mobilePhoneNumber
    });
  }
  $("#userOId,#nickName,#mobilePhoneNumber").bind("keydown", function (e) {
    if (e.keyCode == 13) {
      search();
    }
  });

  function  add() {
    mini.open({
      url: "/getdata/addSystemSendScore",
      title: "系统发分", width: 400, height: 200,
      ondestroy: function (action) {
        grid.reload();
      }
    });
  }

  function del() {
    let currentRow = grid.getSelected();
    if (currentRow) {
      $.ajax({
        type:"POST",
        url:"/getdata/systemSendScoreDel",
        data:{
          objectId:currentRow.objectId,
          userOId:currentRow.userOId,
          score:currentRow.score
        },
        success:function (result) {
          grid.reload();
        }
      })
    } else {
      alert("请选中一个用户属性!");
      return;
    };
    // var arrRow = grid.getSelecteds();
    // var  ids = [];
    // for(var i = 0;i<arrRow.length;i++){
    //   ids.push(arrRow[i].id);
    // }
    // if(ids.length>=1){
    //   $.ajax({
    //     url:'/getdata/systemSendScoreDel',
    //     type:'POST',
    //     data:{
    //       ids
    //     },
    //     success:function (result) {
    //       if(result=="10001"){
    //         alert("删除成功");
    //         grid.reload();
    //       }else{
    //         alert("删除失败");
    //       }
    //     }
    //   })
    // }else {
    //   alert("请选中一条记录");
    // }
  }

</script>
</html>
